package com.algorithm.data_structure;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@Slf4j
public class StringSulotionST01 {
    public String replaceSpace(String s) {
        String reslt = "";
        char[] chars = s.toCharArray();
        for (int i = 0; i <chars.length ; i++) {
            String tmp = String.valueOf(chars[i]);
            if (chars[i]==32){
                tmp = "%20";
            }
            reslt = reslt+tmp;
        }
        return reslt;
    }

    @Test
    @DisplayName("请实现一个函数，把字符串 s 中的每个空格替换成%20 。")
    public void test(){
        String aa = "We are  happy.";
        String s = replaceSpace(aa);
        log.info("result is {}",s);
    }

}
